﻿using BestClient;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RecognitionForm.Core
{
    public class PersonManager
    {
        public static string CreatePerson(string Name, string Code, string Group, string faceTemplate, string devSN, string Gender)
        {
            BestData t = new BestData
            {
                sid = "ems.common.person.synchronize",
                sys = "response",
                sn = devSN,
                message = "ok",
                mid = new Random().Next(-2147483648, 0x7fffffff).ToString()
            };
            t.setPayload("datafmt", "1");
            List<object> map = new List<object>();
            Dictionary<string, object> item = new Dictionary<string, object>();
            Hashtable hashtable = new Hashtable();
            hashtable.Add("accAuth", "Y");
            hashtable.Add("groupId", Group);
            hashtable.Add("birthday", "1993-05-23 00:00:00");
            hashtable.Add("name", Name);
            hashtable.Add("gender", Gender);
            hashtable.Add("code", Code);
            hashtable.Add("photo", faceTemplate);
            hashtable.Add("isNew", "true");
            List<string> list2 = new List<string> {
        MessageConverter.toJson<Hashtable>(hashtable)
    };
            item.Add("persons", list2);
            item.Add("count", item.Count.ToString());
            map.Add(item);
            t.setPayloadResult(map);
            return MessageConverter.toJson<BestData>(t);
        }


        public static string DeletePerson(string[] Code, string Group, string devSN)
        {
            BestData t = new BestData
            {
                sid = "cpe.ems.person.delete",
                sys = "response",
                sn = devSN,
                message = "ok",
                mid = new Random().Next(-2147483648, 0x7fffffff).ToString()
            };
            List<object> list = new List<object>();
            Dictionary<string, object> dictionary = new Dictionary<string, object>();
            List<string> list2 = new List<string>();
            list2.AddRange(Code);
            dictionary.Add("codeList", list2);
            t.setPayloadParam("codeList", list2);
            return MessageConverter.toJson<BestData>(t);
        }






    }
}
